<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
Yii::setPathOfAlias('module', dirname(__FILE__).'/../modules');
Yii::setPathOfAlias('common', dirname(__FILE__).'/../../common');
Yii::setPathOfAlias('file', dirname(__FILE__).'/../../files');
Yii::setPathOfAlias('hybridauth', dirname(__FILE__).'/../../auth');
Yii::setPathOfAlias('tmp', dirname(__FILE__).'/../../tmp');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name' => 'WACONTRE',
	'id' => 'wacontre',

	'theme' => 'classic',

	'sourceLanguage' => '00',
	'language' => 'vi',

	// preloading 'log' component
	'preload'=>array('log'),
	'components'=>array(
        'log'=>array(
            'class'=>'CLogRouter',
            'routes'=>array(
                array(
                    'class'=>'CFileLogRoute',
                    'levels'=>'error,info,warning',
                    'categories'=>'system.*',
                ),
            ),
        ),
    ),

	// autoloading model and component classes
	'import'=>array(
		'common.models.*',
		'common.components.*',
		'application.models.*',
		'application.components.*',
		'ext.YiiMailer.YiiMailer',
	),

	'modules'=>array(
		// uncomment the following to enable the Gii tool
		/*
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'Enter Your Password Here',
		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
		),
		*/
	),

	// application components
	'components'=>array(
		// Handling Session
		//Session to database
		'session' => array (
			'sessionName' => 'Site Session',
			'class' => 'CDbHttpSession',
			'autoCreateSessionTable' => false,
			'connectionID' => 'db',
			'sessionTableName' => '{{sessions}}',
			'useTransparentSessionID' =>true,
			'cookieMode' => 'only',
			'timeout' => 1200,
			//'cookieParams' => require(dirname(__FILE__).'/../../common/config/cookie.php'),
		),
		 
		//Session to file
		/*
		'session' => array(
			'sessionName' => 'Site Session',
			'class'=>'CHttpSession',
			'useTransparentSessionID'   =>($_POST['PHPSESSID']) ? true : false,
			'autoStart' => 'false',
			'cookieMode' => 'only',
			'savePath' => '/Users/NguyenKiet/Sites/Log',
			'timeout' => 300
		),
		*/
		'cache'=>array(
			'class' => 'system.caching.CFileCache',
			'directoryLevel' => 1,
		),		
		'user'=>array(
			// enable cookie-based authentication
			'class'=>'application.components.WebUser',
			'allowAutoLogin'=>true,
		),
		// uncomment the following to enable URLs in path-format
		'urlManager' => array(
			'showScriptName' => false, 
			'urlFormat' => 'path',
			'rules' => array(
				''														=> 'site/index', 
				'<name:.*?>-p<pid:\d+>'									=> 'product/view',
				'<name:.*?>-c<id:\d+>'									=> 'category/view',
				'search'												=> 'site/search',  
				'login'													=> 'user/login',
				'logout'												=> 'user/logout',
				'register-account'										=> 'user/register',
				'lost-password'											=> 'user/forgotPassword',
				'my-account'											=> 'user/account',
				'my-profile'											=> 'user/profile',
				'search-user'											=> 'user/findFriends', 
				'make-friend/<name:.*?>/'								=> 'user/acceptFriend',
				'make-friend-cancel/<name:.*?>/'						=> 'user/rejectFriend',
				'make-friends/<name:.*?>/'								=> 'user/friend',
				'u/<name:.*?>/'											=> 'user/view', 
				'<controller:\w+>/<id:\d+>/<name:.*?>'					=> '<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>/<page:\d+>'		=> '<controller>/<action>',
				'<controller:\w+>/<action:\w+>/<id:\d+>'				=> '<controller>/<action>',
				'<controller:\w+>/<action:\w+>'							=> '<controller>/<action>', 
				'admin-page' 											=> 'user/adminpage'
			),
			'urlSuffix' => '.html'
		),
//		'db'=>array(
//			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
//		),
		// uncomment the following to use a MySQL database
		
		'db'=>require(dirname(__FILE__).'/../../common/config/db.php'),
		
		'errorHandler'=>array(
			// use 'site/error' action to display errors
            'errorAction'=>'site/error',
        ),
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error,info,warning',
					'enabled' => false,
					'categories' => 'info,system.*',
					'logPath' => dirname(__FILE__).'/../../files/log/', 
					'logFile' => date('Ymd')
				),
				//Log to database
				array(
					'class'=>'CDbLogRoute',
					'levels'=>'error,info,warning',
					'autoCreateLogTable' => true,
					'connectionID' => 'db',
					'enabled' => true,
					'categories' => 'info,system.*'
				),
				// uncomment the following to show log messages on web pages
				//array(
				//	'class'=>'CWebLogRoute',
				//)
			),
		),
		'image' => array(
			'class' => 'common.extensions.image.CImageComponent',
			'driver' => 'GD',
			'params' => array('directory', dirname(__FILE__).'/../../files'),
		),
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>require(dirname(__FILE__).'/../../common/config/params.php'),
);